home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / cvs-1_3.lha / cvs-1.3 / contrib / mfpipe.pl < prev    next >
Perl Script  |  1992-03-01  |  2KB  |  88 lines

  1. #!/usr/bin/perl
  2. #
  3. # From: clyne@niwot.scd.ucar.EDU (John Clyne)
  4. # Date: Fri, 28 Feb 92 09:54:21 MST
  5. # BTW, i wrote a perl script that is similar to 'nfpipe' except that in
  6. # addition to logging to a file it provides a command line option for mailing
  7. # change notices to a group of users. Obviously you probably wouldn't want
  8. # to mail every change. But there may be certain directories that are commonly
  9. # accessed by a group of users who would benefit from an email notice. 
  10. # Especially if they regularly beat on the same directory. Anyway if you 
  11. # think anyone would be interested here it is. 
  12. #
  13. #      mfpipe.pl,v 1.1 1992/03/02 01:22:41 berliner Exp
  14. #
  15. #
  16. #    File:        mfpipe
  17. #
  18. #    Author:        John Clyne
  19. #            National Center for Atmospheric Research
  20. #            PO 3000, Boulder, Colorado
  21. #
  22. #    Date:        Wed Feb 26 18:34:53 MST 1992
  23. #
  24. #    Description:    Tee standard input to mail a list of users and to
  25. #            a file. Used by CVS logging.
  26. #
  27. #    Usage:        mfpipe [-f file] [user@host...]
  28. #
  29. #    Environment:    CVSROOT    
  30. #                Path to CVS root.
  31. #
  32. #    Files:
  33. #
  34. #
  35. #    Options:    -f file    
  36. #                Capture output to 'file'
  37. #            
  38.  
  39. $header = "Log Message:\n";
  40.  
  41. $mailcmd = "| mail -s  'CVS update notice'";
  42. $whoami = `whoami`;
  43. chop $whoami;
  44. $date = `date`;
  45. chop $date;
  46.  
  47. $cvsroot = $ENV{'CVSROOT'};
  48.  
  49. while (@ARGV) {
  50.         $arg = shift @ARGV;
  51.  
  52.     if ($arg eq '-f') {
  53.                 $file = shift @ARGV;
  54.     }
  55.     else {
  56.         $users = "$users $arg";
  57.     }
  58. }
  59.  
  60. if ($users) {
  61.     $mailcmd = "$mailcmd $users";
  62.     open(MAIL, $mailcmd) || die "Execing $mail: $!\n";
  63. }
  64.  
  65. if ($file) {
  66.     $logfile = "$cvsroot/LOG/$file";
  67.     open(FILE, ">> $logfile") || die "Opening $logfile: $!\n";
  68. }
  69.  
  70. print FILE "$whoami $date--------BEGIN LOG ENTRY-------------\n" if ($logfile);
  71.  
  72. while (<>) {
  73.     print FILE $log if ($log && $logfile);
  74.  
  75.     print FILE $_ if ($logfile);
  76.     print MAIL $_ if ($users);
  77.  
  78.     $log = "log: " if ($_ eq $header);
  79. }
  80.  
  81. close FILE;
  82. die "Write failed" if $?;
  83. close MAIL;
  84. die "Mail failed" if $?;
  85.  
  86. exit 0;
  87.